using System;
using System.Configuration;
using System.ComponentModel;

namespace TrackMe.View
{
	public static class XmlConfig
	{
		public static IConfig LoadConfig()
		{
			var result = AutoIntf.New<IConfig>();
			Type type = result.GetType();
			foreach (var prop in type.GetProperties())
			{
				if (prop.PropertyType == typeof(bool))
					prop.SetValue(result, Convert.ToBoolean(ConfigurationManager.AppSettings[prop.Name]), null);
				else if (prop.PropertyType == typeof(int))
					prop.SetValue(result, Convert.ToInt32(ConfigurationManager.AppSettings[prop.Name]), null);
				else
					prop.SetValue(result, ConfigurationManager.AppSettings[prop.Name], null);
			}
			return result;
		}

	}
}
